package com.web.onirigi.controller;


import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.parsing.ParseState;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.web.onirigi.util.BaseResponseObject;
import com.web.onirigi.util.ParseJsonToMap;
import com.web.onirigi.util.RequestObject;



@RestController
public class TestRest {

	/**
	 * 日志
	 */
	private static final Logger logger =LoggerFactory.getLogger(TestRest.class);
	
	/**
	 * 返回测试数据
	 * @return
	 */
	@RequestMapping(value="getObject",method=RequestMethod.GET)
	public BaseResponseObject  testMethod() {
		BaseResponseObject  object =new BaseResponseObject();
		object.setResponseCode("2220");
		
		return object;
		
	}
	
	/**
	 * 测试
	 * @author ASUS
	 * 创建时间  2017年10月2日 下午5:22:09
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping(value="getJson",method=RequestMethod.POST)
	public BaseResponseObject  testMethod(@RequestBody   String  json) throws Exception {
		Map map=ParseJsonToMap.parseStringToMap(json);
		logger.info(map.toString());
		int a=(int)map.get("a");
		int b=(int) map.get("b");
		int c=a+b;
		BaseResponseObject  object =new BaseResponseObject();
		object.setResponseCode(String.valueOf(c));
		
		return object;
		
	}
	

	
}
